﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

using System.Globalization;
using System.Threading;
using System.Resources;
using System.Collections.Generic;

using MapCenterSystem.DataInfo;
using MapCenterSytem.Process;
using MapCenterSystem.ServiceProvider.GoogleMap;
using System.Drawing;
using System.Drawing.Imaging;
using MapCenterSystem.DefineType;


namespace MobiMap.Guest
{
    public partial class Home : System.Web.UI.Page
    {
        ResourceManager rm;
        CultureInfo ci;

        protected void Page_Load(object sender, EventArgs e)
        {            

            imgMap.Attributes.Add("onload", "changedImageMap();");

            if (!IsPostBack)
            {
                HtmlControl divToolbar = (HtmlControl)Master.FindControl("divToolbar");
                divToolbar.Style["display"] = "none";

                HtmlControl mainCanvas = (HtmlControl)Master.FindControl("mainCanvas");
                mainCanvas.Style["max-height"] = "512px";
            }

            if (Session["MAP"] != null)
            {
                MapInfoEx map = (MapInfoEx)Session["MAP"];
                cmbMode.SelectedIndex = map.MapType;
            }
                

            //Language
            rm = new ResourceManager("Resources.SiteMap", System.Reflection.Assembly.Load("App_GlobalResources"));
            HtmlImage imgLanguage = (HtmlImage)Master.FindControl("idLanguage");
            if (Request.Cookies["language"] != null)
            {
                string language = Request.Cookies["language"].Value;
                Thread.CurrentThread.CurrentCulture = new CultureInfo(language);
                LoadString(Thread.CurrentThread.CurrentCulture);
                
                imgLanguage.Src = "../Image/" + language + ".png";
                return;
            }

            //Defaut language is Vietnamese
            Thread.CurrentThread.CurrentCulture = new CultureInfo("vi-VN");
            ci = Thread.CurrentThread.CurrentCulture;
            LoadString(ci);
            imgLanguage.Src = "../Image/" + "vi-VN" + ".png";
        }

        public void LoadString(CultureInfo ci)
        {
            cmbMode.Items[0].Text = rm.GetString("Mode_Map", ci);
            cmbMode.Items[1].Text = rm.GetString("Mode_Satellite", ci);
            cmbMode.Items[2].Text = rm.GetString("Mode_Hybrid", ci);

            infoTitle.InnerHtml = rm.GetString("Info_lbTitle", ci);
            infoDirection.Text = rm.GetString("Info_linkDirection", ci);
            infoNearBy.Text = rm.GetString("Info_linkNearBy", ci);
        }

    }
}
